@extends('layouts.admin')
@section('content')
    <div id="ribbon"><ol class="breadcrumb"><li>内容区</li></ol></div>
    <div class="content_wrapper">
        <aside>
            <header><i class="fa fa-fw fa-file"></i>公共Banner列表</header>
            <section>
                <div class="row">
                    <div class="col-sm-12">
                        <form action="" method="get">
                            <div class="btn-group">
                                <a href="{{url('admin/banner/add')}}" class="btn btn-default">
                                    <i class="fa fa-plus"></i>添加Banner
                                </a>
                            </div>
                        </form>
                        <div class="table-responsive" style="margin-top:10px;">
                            <table id="example" class="table table-striped table-bordered table-hover" cellspacing="0"
                                   width="100%">
                                <thead>
                                <tr>
                                    <th>图片</th>
                                    <th>序号</th>
                                    <th>状态</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                    @foreach($list as $value)
                                        <tr>
                                            <td>
                                                <img src="{{$value['pic']}}" style="max-height:100px">
                                            </td>
                                            <td>{{$value['order_num']}}</td>
                                            <td>{{$value['status'] == 1 ? '正常' : '冻结'}}</td>
                                            <td>{{$value['created_at']}}</td>
                                            <td>
                                                <a href="{{url('admin/banner/edit?id=' . $value['id'])}}" class="btn btn-success btn-xs">编辑</a>
                                                <button type="button" onclick="del('{{$value['id']}}')" class="btn btn-danger btn-xs">删除</button>
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                        <nav>{!! $list->appends($params)->render() !!}</nav>
                    </div>
                </div>
            </section>
        </aside>
    </div>
    <script>
        function del(id) {
            if (confirm('确定要删除吗？')) {
                $.get('{{url('admin/banner/del')}}', {id: id}, function () {
                    location.reload();
                });
            }
        }
    </script>
@endsection